<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script src="../js/Calendar.js" language="javascript"></script>
<title>教师信息维护</title>
<style type="text/css">
body {
	margin:0px;
}
.list_content {
	background-color: #fff;
	color:#73938E;
	font-size:12px;
	line-height:15px;
	text-align:center;
}
.list_top_title {
	font-size:12px;
	background-color: #F3F8F7;
	color:#73938E;
	font-weight:bold;
	line-height:30px;
	text-align:center;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
}
.fenye{
    clear:both;
	text-align:center;	
}
.fenye dt { 
    text-align:center;
	float: left; 
	margin: 2px; 
	padding: 0 5px 0 5px; 
}
</style>
</head>
<script language="javascript">
function delcfm(){
    if(!confirm("确认要删除教师信息吗？")){
        window.event.returnValue = false;
    }
}
 	function deleteid(id){
		if(confirm('你确定要删除记录吗?')){
		    window.location="list_teacher.php?action=delete&id="+id;
		}
	}
	function checkform(){
		if(confirm("你确定要删除记录吗?"))
			return true; 
		else
			return false;
	}
	function TogSel(str)
	{
		var ems = document.getElementsByName(str);
		for(i=0; i < ems.length; i++)
		{
			ems[i].checked=!ems[i].checked;
			/*if(ems[i].checked==true) 
				ems[i].checked=false;
			else 
				ems[i].checked=true;*/
		}
	}
	function checkAll(str)
	{
	  var a = document.getElementsByName(str);//取得选择框
	  var n = a.length;//获取选择框的长度
	  for (var i=0; i<n; i++)
	  a[i].checked = true;//将全选框的选择状态赋给下面的选择框
	}
</script>
<body>
<?php
 session_start();

 include("../main/function.php");
 include("../main/ShowPage.class.php");
 include("../main/islogin.php");
 $db=new Db();
 $type=$_SESSION['type'];

if($_POST['search'])
{
	$search_name=$_POST['search_name'];
	$search_sex=$_POST['search_sex'];
	$search_idcard=$_POST['search_idcard'];
	$search_area=$_POST['search_area'];
	//拼装搜索条件
	if($search_name){
	   $swhere.=" and a.name like '%".$search_name."%'";	
	}
	if($search_sex){
	   $swhere.=" and a.sex='".$search_sex."'";
	}
	if($search_idcard){
	   $swhere.=" and a.idcard;='".$search_idcard."'";
	}
	if($search_area){
	   $swhere.=" and a.area='".$search_area."'";
	}
	$sql="SELECT  a.id as id,a.name as name,b.name as aname, a.* FROM teacher a ,area b,education c where a.area=b.id and a.education=c.id $swhere order by a.id ";	
}
else
{
	switch($type)
	{
		case 3: $sql ="select teacher.id as id,teacher.name as name,sex,birth,idcard,area.name as aname,title,phone from teacher,area where 					teacher.area=area.id "; break;
		case 2:  $area_id=$_SESSION['area_id']; $sql ="select teacher.id as id,teacher.name as name,sex,birth,idcard,area.name as aname,title,phone from teacher,area where teacher.area=$area_id and teacher.area=area.id"; 	 break;			
	}
}
 //分页处理
 $num=$db->rowNum($sql);//获取表记录数
 $page=new ShowPage();//建立分页对象page
 $page->PageSize=15;//设置分页显示的条数
 $page->Total=$num;
 $page->LinkAry=array();
 $showpage=$page->ShowLink();//设置分页导航
 $limit=$page->OffSet(); 
 $userInfo=$db->fetchRows($sql." limit $limit"); 
 ?>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
  <TR height=28 >
    <TD background=../images/title_bg1.jpg>-->当前位置:教师信息维护</TD>
</TR>
<tr>
<td>&nbsp;</td>
</tr>
</TABLE>

<form action="#" method="post" onsubmit="">
  
  <table width="99%" border="1" align="center"  cellpadding="3" cellspacing="0"  bordercolor="#F3F8F7" >
    <tr height="15px">
      <td class="list_top_title">姓名：</td>
      <td class="list_content"><input name="search_name" type="text" id="search_name"  size="14" /></td>
      <td class="list_top_title">性别</td>
      <td class="list_content">
      <select name="search_sex" id="search_sex">
	  		<option value="" >--选择性别--</option>
            <option  value="男">男</option>
            <option  value="女">女</option>
      </select>
      </td>      
      <td class="list_top_title">身份证号码</td>
	   <td class="list_content">
       <input maxlength="18"   type="text" name="search_idcard" id="search_idcard"  />
       </td>
      <td class="list_top_title">所在院系</td>
      <td class="list_content">
	  <select style="width:180px;" name="search_area" id="search_area" onchange="getData('../teacher/getsearcharea.php?id='+this.value,'area2');">
	  			<option value="" >--选择院系--</option>
                <option value="100">机械与汽车工程系</option>
                <option value="101">信息工程系</option>
                <option value="102">工业自动化系</option>
				<option value="103">汽车工程系</option>
				<option value="104">建筑工程系</option>
				<option value="105">经济与管理学院</option>
				<option value="106">会计系</option>
				<option value="107">外语系</option>
				<option value="108">体育系</option>
				<option value="109">思想政治教育部</option>
				<option value="110">基础课教育部</option>

		</select>
	    </span>
        </td>
     </tr>	
	<tr>
	  <td colspan="8" class="list_content">
      	<input  class="inputButton" type="submit" name="search" value="查询" />				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<!--	    <input  class="inputButton" type="submit" name="submit2" value="数据导出" onclick="javascript:document.location.href='report.php'"  href="report.php"/>-->
		<?php  echo "<a href='report.php'><input type='button' value='数据导出'></a>"; ?> </td>
    </tr>
  </table>
  </form>
  <form action="" method="post" onsubmit="return checkform();">
  <table width="99%"   border="1" align="center"  cellpadding="3" cellspacing="0"  bordercolor="#F3F8F7" >
    <tr height="30">
      <td width="4%" class="list_top_title" ><a href="javascript:checkAll('id[]');"">全选</a>/<a href="javascript:TogSel('id[]');" >反选</a></td>
      <td width="6%" class="list_top_title">编号</td>
      <td width="8%" class="list_top_title" >姓名</td>
	  <td width="4%" class="list_top_title" >性别</td>
	  <td width="12%" class="list_top_title" >出生年月</td>
	  <td width="18%" class="list_top_title">身份证号</td>
      <td width="18%" class="list_top_title" >院系</td>
      <td width="8%" class="list_top_title">职称</td>
	  <td width="8%" class="list_top_title">手机号</td>
      <td width="14%" class="list_top_title" >操作</td>
    </tr>
   <?PHP $n=0; while($n<15) { 
   		if($userInfo[$n]['id']==NULl) break;	 ?> 
    <tr>
      <td class="list_content"><input name="id[]" type="checkbox" value="<!--{$teacher[f].id}-->" /></td>
      <td class="list_content"><?php echo $userInfo[$n]['id'] ?>&nbsp;</td>
      <td class="list_content"><?php echo $userInfo[$n]['name'] ?>&nbsp;</td>
      <td class="list_content"><?php echo $userInfo[$n]['sex'] ?>&nbsp;</td>
	  <td class="list_content"><?php echo $userInfo[$n]['birth'] ?>&nbsp;</td>
	  <td class="list_content"><?php echo $userInfo[$n]['idcard'] ?>&nbsp;</td>
      <td class="list_content"><?php echo $userInfo[$n]['aname'] ?>&nbsp;</td>
      <td class="list_content"><?php echo $userInfo[$n]['title'] ?>&nbsp;</td>
      <td class="list_content"><?php echo $userInfo[$n]['phone'] ?>&nbsp;</td>
      <td class="list_content"><a href="details.php?action=<?php echo $userInfo[$n]['id'] ?>">详细资料</a>|<a href="../teacher/delete_teacher.php?Id=<?php echo $userInfo[$n]['id'] ?>" onclick="delcfm()">删除</a></td>
	 <?php   $n=$n+1;} ?>
    </tr>
    <tr>
      <td class="list_content"><input  type="submit" value="删除选中" name="submit"  /></td>
      <td colspan="9"  class="list_content"><div class="fenye"><?php echo $showpage; ?></div></td>
    </tr>
  </table>
</form>
</body>
</html>
